package edu.pku.sei.autounit.generator;


import edu.pku.sei.autounit.core.Variable;
import edu.pku.sei.autounit.core.VariableFactory;
import edu.pku.sei.autounit.core.VariableGenerator;
import edu.pku.sei.autounit.filter.Filter;
import edu.pku.sei.autounit.reflect.Class;
import edu.pku.sei.autounit.reflect.Constructor;
import edu.pku.sei.autounit.reflect.Type;
import edu.pku.sei.autounit.util.NameFactory;

public class ClassGenerator implements VariableGenerator {

	public Variable generate(Type type,String name,VariableFactory vf,NameFactory nf) {
		if(!(type instanceof Class))
			return null;
		Class c = (Class)type;
		if(c.canInstantiation()){
			Constructor constructor = null;
			int min = 100;
			for(Constructor con:c.getPublicConstructors()){
				if(con.getParameters().length<min){
					min = con.getParameters().length;
					constructor = con;
					if(min == 0)
						break;
				}
			}
			return new ConstructorInvoke(type,name,constructor,vf,nf);
		}
		return null;
	}
	
	public Variable generate(Type type, String name, Filter fliter,
			VariableFactory vf, NameFactory nf) {
		// TODO Auto-generated method stub
		return null;
	}
}
